import requests
from bs4 import BeautifulSoup as bs
import json

data = requests.get('http://data.sports.sohu.com/nba/nba_players_rank.html')

soup = bs(data.content, 'lxml')

list = soup.find('table', class_='table01').find_all('tr')

json = {}
index = 0
for li in list:
    rank = {"排名": li.find_all('td')[0].get_text()}
    name = {"球员": li.find_all('td')[1].get_text()}
    team = {"球队": li.find_all('td')[2].get_text()}
    time = {"出场次数": li.find_all('td')[3].get_text()}
    avr = {"场均时间": li.find_all('td')[4].get_text()}
    score = {"得分": li.find_all('td')[5].get_text()}
    hand = {"命中/出手": li.find_all('td')[6].get_text()}
    hand_rate = {"命中率": li.find_all('td')[7].get_text()}
    three = {"命中/三分": li.find_all('td')[8].get_text()}
    three_rate = {"三分命中率": li.find_all('td')[9].get_text()}
    punish = {"命中/罚球": li.find_all('td')[10].get_text()}
    punish_rate = {"罚球命中率": li.find_all('td')[11].get_text()}
    json[index] = {rank, name, team, time, avr, score, hand, hand_rate, three, three_rate, punish, punish_rate}
    index += 1
print(json)
